home *** CD-ROM | disk | FTP | other *** search
- `Here's a console function to get user input and display text.
- `You can change the size of the text area, and when you get to the
- `bottom, it scrolls up.
-
- `Send con():
- `"cr" for a carriage return (new line)
- `"input" to get input string and assign it to answer$(1)
- `any other string to print it to screen with word wrap...
-
- `until there's an Image Exists() command, use a global flag...
- dim imageflag(1)
- `answer$(1) holds what the user inputs...
- dim answer$(1)
-
- `ask enough times to demonstrate scrolling...
- for j=1 to 2
- con("What's your name? ")
- con("input")
- name$=answer$(1)
- a$="Whaaaazzzup, " + name$ + " !!! "
- con(a$)
- a$="Here's a test string, " + name$ + ". "
- for k=1 to 5
- con(a$)
- next k
- con("cr")
- con("cr")
- next j
-
- `clean up...
- if imageflag(1)=1 then delete image 99
- undim imageflag(1)
- undim answer$(1)
- end
-
- FUNCTION con(a$)
- `Change these 6 values as needed, all values in pixels.
- `Make left & right margins > 0, make top & bottom margins
- `multiples of text height, which by default is 16.
- screenwidth=640 : screenheight=480
- leftmargin=25 : rightmargin=25
- topmargin=16 : bottommargin=16*23
-
- aheight=text height(a$)
- if xover<leftmargin then xover=leftmargin
- if ydown<topmargin then ydown=topmargin
- nextline$=""
- answer$(1)=""
-
- do
- alen=len(a$)
- `get rid of any spaces at beginning of a$...
- while left$(a$,1)=" "
- dec alen
- a$=right$(a$,alen)
- endwhile
-
- `carriage return -- moves cursor to next line...
- if a$="cr"
- xover=leftmargin
- ydown=ydown+aheight
- gosub scrollcheck
- set cursor xover,ydown
- EXITFUNCTION
- endif
-
- `get input from user, assign it to answer$(1)
- if a$="input"
- `comment out next 3 lines to get user input on same line...
- xover=leftmargin
- ydown=ydown+aheight
- gosub scrollcheck
- set cursor xover,ydown
- input answer$
- xover=leftmargin
- ydown=ydown+aheight
- gosub scrollcheck
- answer$(1)=answer$
- EXITFUNCTION
- endif
-
- awidth=text width(a$)
- room=screenwidth-rightmargin-xover
- `if there's room on the line, display a$, exit do-loop...
- if awidth<room
- text xover,ydown,a$
- xover=xover+awidth
- exit
- endif
-
- `...otherwise go backwards along a$,
- `moving the last character into nextline$
- `until a$ is short enough to fit...
- while awidth>room
- nextline$=right$(a$,1)+nextline$
- dec alen
- a$=left$(a$,alen)
- awidth=text width(a$)
- endwhile
-
- `then count back until it hits a space,
- `so you don't break mid-word...
- righ$=right$(a$,1)
- while righ$<>" " and alen>0
- nextline$=righ$+nextline$
- dec alen
- a$=left$(a$,alen)
- righ$=right$(a$,1)
- endwhile
-
- `print a$ to screen...
- text xover,ydown,a$
- `and make nextline$ the new a$...
- a$=nextline$ : nextline$=""
- xover=leftmargin : ydown=ydown+aheight
-
- `scroll it off the top if necessary...
- gosub scrollcheck
- loop
- EXITFUNCTION
-
- scrollcheck:
- if ydown=>screenheight-bottommargin
- x2=screenwidth-rightmargin : y2=screenheight-bottommargin
- if y2>screenheight then y2=screenheight
- get image 99,leftmargin,topmargin+aheight,x2,y2
- paste image 99,leftmargin,topmargin
- ink 0,0
- box leftmargin,screenheight-bottommargin-aheight,x2,y2
- ink rgb(255,255,255),0
- ydown=screenheight-bottommargin-aheight
- imageflag(1)=1
- endif
- return
- ENDFUNCTION
-